﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

using Microsoft.AspNet.SignalR;
using System.Web.Security;

/// <summary>
/// LoginHub 的摘要描述
/// </summary>
public class LoginHub : Hub
{
    public void SendMessage(string message)
    {
        // Call the broadcastMessage method to update clients.
        Clients.All.GetMessage(message);
    }
    public void SendConnectionId()
    {
        Clients.Client(Context.ConnectionId).GetConnectionID(Context.ConnectionId);
    }
    public void SendRedirect(string sip_number, string time_stamp, string custom_name, string user_dir, string survey_id)
    {
        //FormsAuthentication.RedirectFromLoginPage(sip_number, true);
        // "../" For IE 跳轉頁面會跳到/SignalR/CCP_Drive.aspx 的Bug

        //先不加密
        /*
        Clients.Client(Context.ConnectionId).GetRedirect("../../Survey/" + CF.SurveyPage + "?" + 
            CF.QS_sip_number + "=" + sip_number + "&" +
            CF.QS_survey_id + "=" + survey_id + "&" +
            CF.QS_time_stamp + "=" + time_stamp);
        */

        //加密
        Clients.Client(Context.ConnectionId).GetRedirect("../../Survey/" + CF.SurveyPage + "?" +
            CF.QS_sip_number + "=" + CF.EncodeString(sip_number) + "&" +
            CF.QS_survey_id + "=" + survey_id + "&" +
            CF.QS_time_stamp + "=" + CF.EncodeString(time_stamp) );
    }
}

public partial class QR_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
}